<template>
  <div class="app-container">
    <el-form ref="form" :model="course" label-width="120px">
      <el-form-item label="课程名">
        <el-input v-model="course.cname"/>
      </el-form-item>
      <el-form-item label="课程简介">
        <el-input v-model="course.info"/>
      </el-form-item>
      <el-form-item label="课时">
        <el-input v-model="course.hours"/>
      </el-form-item>
      <el-form-item label="学分">
        <el-input v-model="course.score"/>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">新增课程</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'

export default {
  data() {
    return {
      course: {
        cname: '',
        info: '',
        hours: '',
        score: ''
      },
    }
  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url: "/edu/course/save.do",
        method: "POST",
        data: this.course
      }).then(res => {
        if (res.code == 0) {
          //跳转到列表页面
          this.$router.push("/courselist");
        }
      })
    },
    checkPass() {
    },
    onCancel() {
      this.$message({
        message: '取消教师的新增',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line {
  text-align: center;
}
</style>
